
from libs.exception import BaseHTTPException
from flask_babel import gettext as _

class HTTPSysMenuNotFoundError(BaseHTTPException):
    error_code = "menu_not_found_error"
    description = "The System menu no found.{message}"
    code = 400
    def __init__(self,menu_id:str|None):
        if menu_id:
            self.description = _("The System menu no found.{message}").format(message=menu_id)
        else:
            self.description = _("The System menu no found.")
        super().__init__(description=self.description)

class HTTPSysMenuParamError(BaseHTTPException):
    error_code = "menu_parameter_error"
    description = "The System menu parameter error.{message}"
    code = 400
    def __init__(self,message:str|None):
        if message:
            self.description = _("The System menu parameter error.{message}").format(message=message)
        else:
            self.description = _("The System menu parameter error.")
        super().__init__(description=self.description)

class HTTPSysRoleNotFoundError(BaseHTTPException):
    error_code = "role_not_found_error"
    description = "The System role no found.{message}"
    code = 400
    def __init__(self,role_id:str|None):
        if role_id:
            self.description = _("The System role no found.{message}").format(message=role_id)
        else:
            self.description = _("The System role no found.")
        super().__init__(description=self.description)

class HTTPDelBuildInRoleError(BaseHTTPException):
    error_code = "role_del_error"
    description = "Cannot delete built-in roles."
    code = 400
    def __init__(self):
        self.description = _("Cannot delete built-in roles.")
        super().__init__(description=self.description)